package bookdata.tofile;

import java.io.FileWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;

import com.oocl.dao.pojo.Book;

public class BookDataToFileXML {
	private List<Book> bList;

	public List<Book> getBookData() {
		bList = new ArrayList<Book>();
		Book[] book = new Book[10000];
		for (int i = 0; i < 10000; i++) {
			book[i]=new Book(i, "Java" + i, new Date(), "Weir" + i, 35.45, true, "机械出版社");
			bList.add(book[i]);
		}
		return bList;

	}
//	public void bookDataToFileXML(){
//
//		Element root=new Element("books");
//		Document doc=new Document();
//		doc.setRootElement(root);
//		for (int i = 0; i < 10; i++) {
//			Element bookEle=new Element("book");
//			bookEle.setAttribute("id","b"+i);
//			Element nameEle=new Element("name");
//			nameEle.setText("book"+i);
//			
//			Element priceEle=new Element("price");
//			priceEle.setText(i+3+"");
//			root.addContent(bookEle);
//			bookEle.addContent(nameEle);
//			bookEle.addContent(priceEle);			
//		}
//		Writer w=new FileWriter("book1.xml");
//		XMLOutputter xOutputter=new XMLOutputter(Format.getPrettyFormat());
//		xOutputter.output(doc, w);	
//	
//	}
	
	
}
